#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int i = 0;
	int a = 0;
	int b = 0;
	int t = 0;
	int min = 0;
	scanf("%d%d", &a, &b);
	if (a > b)
		min = b;
	else
		min = a;
	for (i = 1; i <= min; i++)
	{
		if (a % i == 0 && b % i == 0)
			t = i;
	}
	printf("%d", t);
	return 0;
}